import React from 'react';
import {Provider} from 'react-redux'
import {legacy_createStore as createStore } from 'redux'
import Counter from './pages/Counter'
import ReactDOM from 'react-dom/client';

const initialState = {
  count: 0
}

function reducer(state = initialState,action){
  switch(action.type){
    case 'INCREMENT':
      return {
        count: state.count + 1
      }
    case 'DECREMENT':
      return {
        count: state.count - 1 
      }
    default:
      return state
  }
}
const store = createStore(reducer)
const App = () => {
  <Provider store={store}>
    <Counter></Counter>
  </Provider>
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render( <React.StrictMode >
    <App />
    </React.StrictMode>
);
// reducer处理actions